package com.dorm.cj.thread.threadGroup;

import java.util.Random;
import java.util.concurrent.TimeUnit;

public class Main2 {
    public static void main(String[] args) {

        MyThreadGroup threadGroup = new MyThreadGroup("hello");
        for (int i = 0; i < 10; i++) {
            new Thread(threadGroup, () -> {
                try {
                    int i1 = new Random().nextInt(5);
                    System.out.println(Thread.currentThread().getName() + "sleep : " + i1);
                    if (i1 > 3) {
                        throw new RuntimeException("sleep>3");
                    }
                    TimeUnit.SECONDS.sleep(i1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }).start();
        }
    }
}
